package com.jiahua.user.biz.model;

import java.io.Serializable;
import java.util.List;

import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.Lob;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;

@Entity
@Table(name = "InventoryItem")
@NamedQuery(name = "InventoryItem.findAll", query = "SELECT i FROM InventoryItem i")
public class InventoryItem implements Serializable {
	private static final long serialVersionUID = 1L;

	@Id
	@Column(name = "inventoryItemID")
	private String inventoryItemID;

	@Column(name = "CartDesciption")
	private String cartDesciption;

	@Column(name = "Description")
	private String description;

	@Column(name = "Flag")
	private int flag;

	@Lob // ②-1 表示该属性是 LOB 类型的字段
	@Basic(fetch = FetchType. LAZY) //②-2 采用延迟加载机制
    
	private byte[] image;

	@Column(name = "Live")
	private int live;

	@Column(name = "LongDesc")
	private String longDesc;

	@Column(name = "Price")
	private double price;

	@Column(name = "Quantity")
	private int quantity;

	private String registrationDate;

	private String shortDesc;

	@Lob // ②-1 表示该属性是 LOB 类型的字段
	@Basic(fetch = FetchType. LAZY) //②-2 采用延迟加载机制
	 private byte[] thumb;

	private String title;

	private String updateDate;

	private String warehousingDate;

	private double weight;

	@ManyToOne
	@JoinColumn(name = "CategoryID")
	private InventoryCategory inventoryCategory;

	// bi-directional many-to-one association to OrderItem
	@OneToMany(mappedBy = "inventoryItem")
	private List<OrderItem> orderItems;

	public InventoryItem() {
	}

	public String getInventoryItemID() {
		return this.inventoryItemID;
	}

	public void setInventoryItemID(String inventoryItemID) {
		this.inventoryItemID = inventoryItemID;
	}

	public String getCartDesciption() {
		return this.cartDesciption;
	}

	public void setCartDesciption(String cartDesciption) {
		this.cartDesciption = cartDesciption;
	}

	public String getDescription() {
		return this.description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public int getFlag() {
		return this.flag;
	}

	public void setFlag(int flag) {
		this.flag = flag;
	}
	
	 public byte[] getImage() {
	 return this.image;
	 }
	
	 public void setImage(byte[] image) {
	 this.image = image;
	 }

	public int getLive() {
		return this.live;
	}



	public void setLive(int live) {
		this.live = live;
	}

	public String getLongDesc() {
		return this.longDesc;
	}

	public void setLongDesc(String longDesc) {
		this.longDesc = longDesc;
	}

	public double getPrice() {
		return this.price;
	}

	public void setPrice(double price) {
		this.price = price;
	}

	public int getQuantity() {
		return this.quantity;
	}

	public void setQuantity(int quantity) {
		this.quantity = quantity;
	}

	public String getRegistrationDate() {
		return this.registrationDate;
	}

	public void setRegistrationDate(String registrationDate) {
		this.registrationDate = registrationDate;
	}

	public String getShortDesc() {
		return this.shortDesc;
	}

	public void setShortDesc(String shortDesc) {
		this.shortDesc = shortDesc;
	}
	
	 public byte[] getThumb() {
	 return this.thumb;
	 }
	
	 public void setThumb(byte[] thumb) {
	 this.thumb = thumb;
	 }

	public String getTitle() {
		return this.title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public String getUpdateDate() {
		return this.updateDate;
	}

	public void setUpdateDate(String updateDate) {
		this.updateDate = updateDate;
	}

	public String getWarehousingDate() {
		return this.warehousingDate;
	}

	public void setWarehousingDate(String warehousingDate) {
		this.warehousingDate = warehousingDate;
	}

	public double getWeight() {
		return this.weight;
	}

	public void setWeight(double weight) {
		this.weight = weight;
	}

	public InventoryCategory getInventoryCategory() {
		return this.inventoryCategory;
	}

	public void setInventoryCategory(InventoryCategory inventoryCategory) {
		this.inventoryCategory = inventoryCategory;
	}

	public List<OrderItem> getOrderItems() {
		return this.orderItems;
	}

	public void setOrderItems(List<OrderItem> orderItems) {
		this.orderItems = orderItems;
	}

	public OrderItem addOrderItem(OrderItem orderItem) {
		getOrderItems().add(orderItem);
		orderItem.setInventoryItem(this);

		return orderItem;
	}

	public OrderItem removeOrderItem(OrderItem orderItem) {
		getOrderItems().remove(orderItem);
		orderItem.setInventoryItem(null);

		return orderItem;
	}

}